package com.gomore.opple.module.redpackage.adapter;

import android.app.Activity;
import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.gomore.opple.R;
import com.gomore.opple.utils.DensityUtil;
import com.gomore.opple.web.cgform.lottery.entity.TODrawEntity;
import com.gomore.opple.widgets.adapter.CommonAdapter;
import com.gomore.opple.widgets.adapter.ViewHolder;

import java.util.List;

/**
 * Created by asus on 2017/6/2.
 */
public class RedPackageDetailAdapter extends CommonAdapter<TODrawEntity> {
    Activity mactivity;
    Context mContext;
    TODrawEntity mtoDrawEntity;
    int height, width;

    public RedPackageDetailAdapter(Activity activity, Context context, int layoutId, List<TODrawEntity> toDrawEntityList) {
        super(context, layoutId, toDrawEntityList);
        mactivity = activity;
        mContext = context;
        int screenWidth = DensityUtil.screenWith(mactivity);
        width = (screenWidth - DensityUtil.dip2px(mContext, 80)) / 3;
        height = width * 108 / 105;
    }

    @Override
    protected void convert(ViewHolder holder, final TODrawEntity toDrawEntity, final int position) {
        mtoDrawEntity = toDrawEntity;
        ImageView image_view = holder.getView(R.id.image_view);
        TextView text_view = holder.getView(R.id.text_view);
        Glide.with(mContext)
                .load(R.mipmap.red_package_bg)
                .asBitmap()
                .centerCrop()
                .override(width, height)
                .placeholder(R.mipmap.goods_place)
                .into(image_view);

        if (toDrawEntity.getMoney() != null) {
            text_view.setText("¥" + toDrawEntity.getMoney().toString());
        }
    }
}
